//创建express实例
const express = require('express')
//application/json  application/x-www-form-urlencoded解析器
const bodyParser = require('body-parser');

const maincontroller = require('./controller/maincontroller')
const filter = require('./filter/mainfilter')

var path = require("path")
let app = express()
const port = 3000;

//使用post方法解析器
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({
    extended: false
}))

app.use(filter)
//配置总路由
app.use('/api', maincontroller)

//配置静态页面支持
app.use(express.static(path.join(__dirname, '/page')));

//开启监听
app.listen(port, function () {
    console.log(`success listen at http://127.0.0.1:${port}`)
})